Least squares minimization